package basicQuiz

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method("POST")
        url(value(producer("/api/v3/basicQuizzes/students/1/assignments/1/quizzes")
                , consumer(regex("/api/v3/basicQuizzes/students/\\d+/assignments/\\d+/quizzes"))))
//                                        /api/v3/basicQuizzes/students/1/assignments/1/quizzes
        body("""
            [{   
                "quizId":1,
                "userAnswer":"A"
            }]
            """)
        bodyMatchers {
            jsonPath('$[*].quizID', byRegex(number()))
            jsonPath('$[*].userAnswer', byRegex("[\\s\\S]+"))
        }
        headers {
            contentType(applicationJson())
        }
    }
    response {
        status(200)
        body("""
            [
                "true"
            ]
        """)
        bodyMatchers {
            jsonPath('$[*]', byType())
        }
        headers {
            contentType(applicationJson())
        }
    }
}
